/**
 * Copyright (c) 2005 - 2007 FeyaSoft Corp. All Rights Reserved.
 */
package com.feyaSoft.home.web.feedback;

import java.util.Iterator;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.feyaSoft.home.hibernate.feedback.Feedback;

/**
 * @author Fenqiang Zhuang
 * @Oct 10, 2007
 * 
 * This file is used to .....
 */
public class FeedbackJson {
	private int totalCount;
	private List results = null;

	public List getResults() {
		return results;
	}

	public void setResults(List results) {
		this.results = results;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public JSONObject toJSONObject() throws Exception {
		JSONObject json = new JSONObject();
		json.put("totalCount", totalCount);

		JSONArray jsonItems = new JSONArray();
		for (Iterator iter = results.iterator(); iter.hasNext();) {
			Feedback feedback = (Feedback) (iter.next());
			jsonItems.put(feedback.toJSONObject());
		}
		json.put("results", jsonItems);

		return json;
	}
}
